class AuthenticateStafferService
  include Serviceable
  include StatusObject
  def initialize(staffer,password)
    @staffer = staffer
    @password = password
  end

  def call
    return  Status.new(message: "账号或者密码错误!", success: false)   if !user?
    return  Status.new(message: '恭喜您登陆成功！', success: true)
  end

  def user?
    @staffer.present? && password_correct?
  end

  def password_correct?
    @staffer.encrypted_password == @staffer.encrypt_with_salt(@password,@staffer.salt)
  end
end
